/*************************************************************************
 * Copyright 2008 David Almilli
 *  
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *  
 *     http://www.apache.org/licenses/LICENSE-2.0 
 *      
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 **************************************************************************/
package com.tivo.hme.samples.bananas;

import com.tivo.hme.bananas.BApplicationPlus;
import com.tivo.hme.bananas.BEvent;
import com.tivo.hme.bananas.BViewPlus;
import com.tivo.hme.bananas.IBananasPlus;
import com.tivo.hme.bananas.BSkin.Element;
import com.tivo.hme.bananas.layout.Layout;
import com.tivo.hme.bananas.layout.LayoutManager;

public class PleaseWaitScreen extends BananasSampleScreen {
	private BViewPlus pleaseWait;

	public PleaseWaitScreen(BApplicationPlus app) {
		super(app);


        LayoutManager lm = new LayoutManager(getNormal());
        Layout safeTitle = lm.safeTitle(this);
        Layout layout = safeTitle;

        Element e = getBApp().getSkin().get(IBananasPlus.H_PLEASE_WAIT);
        layout = lm.size(layout, e.getWidth(), e.getHeight());
        layout = lm.align(layout, A_CENTER, A_CENTER);

        pleaseWait = new BViewPlus(this, layout);
        pleaseWait.setResource(e.getResource());
	}
    
    /**
     * Since there is only one button, we will treat select like a left 
     * action and pop the screen.
     */
    public boolean handleKeyPress(int code, long rawcode) 
    {
        switch (code) {
        case KEY_SELECT:
        case KEY_LEFT:
            postEvent(new BEvent.Action(this, "pop"));
            getBApp().play("select.snd");
            return true;
        }
        return super.handleKeyPress(code, rawcode);
    }
    
    /**
     *  Title of the screen.
     */
    public String toString() 
    {
        return "Please Wait";
    }

}
